SUBROUTINE probtype(uu,ptypein,typeout)
  USE Commonvars
  IMPLICIT NONE

  REAL(8), INTENT(IN)  :: uu,ptypein(Ntypes)
  INTEGER, INTENT(OUT) :: typeout
  INTEGER :: i

  DO i = 1, Ntypes
     IF (uu < SUM(ptypein(1:i))) THEN
        typeout = i
        EXIT
     END IF
  END DO

END SUBROUTINE probtype
